package com.myhouse;

//特别注意，下面的是 tk.MapperScan

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import tk.mybatis.spring.annotation.MapperScan;

@Controller
@EnableWebMvc
@SpringBootApplication
@MapperScan(basePackages = "com.myhouse.mapper")
//public class Application extends WebMvcConfigurerAdapter implements CommandLineRunner{
public class Application implements CommandLineRunner{
    private Logger logger = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    //平常开发中有可能需要实现在项目启动后执行的功能，SpringBoot提供的一种简单的实现方案就是添加一个model并实现CommandLineRunner接口，
   //实现功能的代码放在实现的run方法中
    @Override
    public void run(String... args) throws Exception {
        logger.debug("debug:服务启动完成!");
        logger.info("info:服务启动完成!");
        logger.warn("warn:服务启动完成!");
        logger.error("error:服务启动完成!");
    }

    @RequestMapping("/")
    String home() {
        return "redirect:houses";
    }
}

